from flask import Flask
from Settings.config import Config
from Models import db
from View.School_blue import school_blue
from View.Student_blue import student_blue
from View.User_blue import user_blue
from flask_cors import CORS
import logging.config
import redis
import yaml

def create_app():

    app = Flask(__name__, instance_relative_config=True) # 下文所指app

    CORS(app, supports_credentials=True, resources={r"/*": {"origins": "*"}})  # 解决跨域的问题

    app.config.from_object(Config())

    db.init_app(app)  # 连接数据库

    app.register_blueprint(school_blue)  # 注册学校蓝图
    app.register_blueprint(student_blue)  # 注册学生蓝图
    app.register_blueprint(user_blue)  # 注册用户蓝图
    #
    # with open(app.config['LOGGING_CONFIG_PATH'], 'r', encoding='utf-8') as f:  # 日志设置
    #     dict_conf = yaml.safe_load(f.read())
    # logging.config.dictConfig(dict_conf)




    return app

